﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Xml.Linq;
using PureMVC.Interfaces;
using GameEngine.Model.Data;

namespace GameEngine.Model
{
    public class IWorldDataProxyConstants<MyIdType>
        where MyIdType : IComparable<MyIdType>
    {
        //public const string THINGCHANGED_NOTIFICATION = "ThingDataProxyChanged";
        //public const string THINGCHANGEDHEIGHT_NOTIFICATIONTYPE = "ThingDataProxyHeightChanged";
        //public const string MAPPOSITIONCHANGED_NOTIFICATIONTYPE = "DataProxyMapPositionChanged";
        //public const string THINGCHANGEDPOSITION_NOTIFICATIONTYPE = "ThingDataProxyPositionChanged";
        public static string CreateDataProxyName(IWorldVO<MyIdType> world)
        {
            return CreateDataProxyName(world.Id);
        }

        public static string CreateDataProxyName(String idValue)
        {
            return idValue + "_worldDataProxy";
        }

        public static string CreateDataProxyName(IWorldVOId id)
        {
            return CreateDataProxyName(id.Value);
        }

        public static IWorldDataProxy<MyIdType> GetWorldDataProxy(IWorldVOId worldName)
        {
            return ApplicationFacade.Instance.RetrieveProxy(CreateDataProxyName(worldName)) as IWorldDataProxy<MyIdType>;
        }
    }

    public interface IWorldDataProxy<MyIdType> : IDataProxy
        where MyIdType : IComparable<MyIdType>
    {
        string THINGADDED_NOTIFICATION { get; }
        string THINGREMOVED_NOTIFICATION { get; }
        string THINGMOVEWITHMOUSE_NOTIFICATION { get; }
        //string TILESIZEUPDATED_NOTIFICATION { get; }
        //string TILEHEIGHTUNITUPDATED_NOTIFICATION { get; }
        //string MAXHEIGHTUPDATED_NOTIFICATION { get; }
        //string MINHEIGHTUPDATED_NOTIFICATION { get; }
        IWorldVOId Id { get; }
        string WorldName { get; set; }

        //Point TileSize
        //{
        //    get;
        //    set;
        //}

        //float MaxHeight
        //{
        //    get;
        //    set;
        //}

        //float MinHeight
        //{
        //    get;
        //    set;
        //}

        //float TileHeightUnit
        //{
        //    get;
        //    set;
        //}

        IWorldVO<MyIdType> VO
        {
            get;
        }

        IMapDataProxy<MyIdType> Map { get; }
        IDictionary<IThingVOId<MyIdType>, IThingDataProxy<MyIdType>> Items { get; }
        IDictionary<Point, List<IThingVOId<MyIdType>>> ItemsMapPosition { get; set; } 
        
        bool Pause { get; set; }

        //void LoadFromXML(XDocument doc);

        //XDocument SaveToXML();

        void Tick();

        void RemoveItem(IThingDataProxy<MyIdType> item);

        void RemoveAllItems();

        void AddItem(IThingDataProxy<MyIdType> item);

        void InitializeItem(IThingDataProxy<MyIdType> item);

        void ControlThingPosition(IThingDataProxy<MyIdType> item);
    }
}
